package com.smag.web.controller.common;

import com.smag.common.core.domain.AjaxResult;
import com.smag.system.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * User: NoahZor
 * date: 2024/4/19
 */
@RestController
@RequestMapping("thirdParty/oss")
@Api("AliOss对象存储服务")
public class AliOssController {

    @Resource
    private OssService ossService;

    @ApiOperation("获取OSS凭证")
    @GetMapping("/policy")
    @PreAuthorize("@ss.hasPermi('thirdParty:oss:policy')")
    public AjaxResult getUploadPolicy() {
        return ossService.getUploadPolicy();
    }

    @ApiOperation("删除文件")
    @DeleteMapping
    @PreAuthorize("@ss.hasPermi('thirdParty:oss:policy')")
    public void deleteFile(@RequestBody String filePath) {
//        System.out.println("Filepath" + filePath);
        ossService.deleteFile(filePath);
    }
}
